1. /* sdfmodf.cpp by K.Tsuru */
  2. // function ID = 3008 DRADIX only
  3. /**********************************************************************
  4. SDouble class
  5. SDouble version for "modf".
  6. It splits 'x' into the integral and decimal parts.
  7. The integral part of SDecimal 'a' can be obtained by an operator a(0),
  8. then an SDouble object only can call.
  9. x = ipart + dpart
  10. For example
  11. x = -1.5
  12. ipart = -1.0
  13. It returns -1.5 - (-1) = -0.5.
  14. ***********************************************************************/
  15. #ifndef SN_H
  16. #include "sn.h"
  17. #endif
  18. SDouble Modf(const SDouble& x, SDouble& ipart){
  19. if(x.Type() != x.REAL) x.SetError(x.RADIX_ERR, "Modf", 3008);
  20. if( (x.NetRdxExp() <= 0) || (x.Sign(3008) == 0) ){
  21. ipart.SetZero(); //integral part is zero
  22. return x;
  23. }
  24. int e = x.RdxExp(); // e > 0
  25. FigBlock blk;
  26. uint n_copy = min( (uint)e + 1, x.Size() ); // e+1 > x.Size() is Ok.
  27. blk.size(n_copy, -1); blk.clear(n_copy);
  28. memcpy(blk.Elements(), x.ReadFigures(), n_copy*sizeof(fType));
  29. ipart.SetFigBlock(blk, x.Sign(), e);
  30. return x - ipart;
  31. }

sdfmodf.cpp : last modifiled at 2017/03/13 14:31:59(1,073 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).